************************************************
***Title: robustness_iv.do
***Creators: Joelle Abramowitz, Shooshan Danagoulian, and Owen Fleming*
***Notes: This file produces the estimates of the effect of pollen exposure on suicide using wind direction as an instrument for pollen exposure. 

*For questions, contact
*Owen Fleming
*hg3490@wayne.edu
************************************************


**********SETUP	
use data/for_analysis, clear

*define macro
global weather_no_wind tmin tmin_sq tmax tmax_sq tmean tmean_sq any_precip


**********PRODUCE ESTIMATES
*Generate sample
ppmlhdfe count ln_pollen_plus1 $weather_no_wind, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
gen sample = e(sample)

*Treatment: location-season quartiles
eststo ols: reghdfe count ln_pollen_plus1 $weather_no_wind if sample==1, absorb(county year_month month_day) cluster(county) tolerance(1e-06)
estadd ysumm
estadd scalar counties = e(N_clust)
estadd local Controls "Weather (excluding wind)" 
estadd local FE "County, Year x Month, Month x Day"

eststo iv_wind_dir: ivreghdfe count (ln_pollen_plus1 = wind_dir_90_180 wind_dir_180_270 wind_dir_270_360) $weather_no_wind if sample==1, absorb(county year_month month_day) cluster(county) first
estadd ysumm
estadd scalar counties = e(N_clust)
estadd scalar F_pollen = e(first)[4,1]
estadd local Controls "Weather (excluding wind)" 
estadd local FE "County, Year x Month, Month x Day"


**********EXPORT
estout using results/robustness_iv.xls, cells(b(star label(Coef.) fmt(4)) se(par(`"="("'`")""') label(Std. Err.) fmt(4))) stats(F_pollen ymean N counties Controls FE) starlevels(* 0.1 ** 0.05 *** 0.01) keep(ln_pollen_plus1) legend label replace 
eststo clear


